package com.web.servlet;

import com.web.entity.Student;
import com.web.service.StudentService;
import com.web.serviceimpl.StudentServiceImpl;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author 17612
 */
@WebServlet("/slogin")
public class SLoginServlet extends HttpServlet{
    StudentService studentService = new StudentServiceImpl();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String Sid = req.getParameter("Sid");
        String Spwd = req.getParameter("Spwd");
        
        Student student=studentService.studentLogin(Sid, Spwd);
        HttpSession session = req.getSession();
        session.setAttribute("s", student);
        
        resp.sendRedirect("studentInfo.jsp");
    }

    @Override
    public String getServletInfo() {
        return "success";
    }

    @Override
    public void destroy() {
    }
}
